package com.dsj.gxrd.modules.activity.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsj.gxrd.modules.activity.domain.entity.RdGroupUser;
import com.dsj.gxrd.modules.activity.mapper.RdGroupUserMapper;
import com.dsj.gxrd.modules.activity.service.RdGroupUserService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author songpin566
 * @date 2023/10/09
 **/
@Service
public class RdGroupUserServiceImpl extends ServiceImpl<RdGroupUserMapper, RdGroupUser> implements RdGroupUserService {

    @Override
    public boolean insertRdGroupUser(Long rdGroupId, List<Long> groupUserIds) {
        if(CollectionUtil.isEmpty(groupUserIds)){
            return false;
        }
        List<RdGroupUser>list=new ArrayList<>();
        for (Long groupUserId : groupUserIds) {
            RdGroupUser groupUser=new RdGroupUser();
            groupUser.setGroupId(rdGroupId);
            groupUser.setUserId(groupUserId);
            groupUser.setDelFlag(0);
            list.add(groupUser);
        }
        return saveBatch(list);
    }

    @Override
    public boolean deleteGroupUserById(Long rdGroupId) {
        return this.lambdaUpdate().eq(RdGroupUser::getGroupId,rdGroupId).remove();
    }


}
